package com.gulimall.auth;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

/**
 * 核心原理
 * 1.@EnableRedisHttpSession 导入了RedisHttpSessionConfiguration 配置
 * 给容器添加了一个组件
 * SessionRepository=>>>    RedisOperationsSessionRepository =>>>   redis 操作session session的增删该查
 * SessionRepositoryFilter session 存储过滤器 每个请求过来都必须经过filter
 *      创建的时候就自动从容器中获取到 SessionRepository;
 *      原始的request, response都被封装    SessionRepositoryRequestWrapper
 *      以后获取session request.getSession()
 *      wrappedRequest.getSession(); ===>   SessionRepository 中获取得到
 *
 *     装饰者模式;
 */


@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableRedisHttpSession  //整合redis 作为存储session
public class GulimallAuthServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(GulimallAuthServerApplication.class, args);
    }

}
/*
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        request.setAttribute(SESSION_REPOSITORY_ATTR, this.sessionRepository);

        SessionRepositoryFilter<S>.SessionRepositoryRequestWrapper wrappedRequest = new SessionRepositoryFilter.SessionRepositoryRequestWrapper
        (request, response, this.servletContext); 包装原始请求对象
        SessionRepositoryFilter.SessionRepositoryResponseWrapper wrappedResponse = new SessionRepositoryFilter.SessionRepositoryResponseWrapper
        (wrappedRequest, response);   包装原始响应对象
        try {
            filterChain.doFilter(wrappedRequest, wrappedResponse);   包装后的对象应用到 整个执行链
        } finally {
            wrappedRequest.commitSession();
        }

    }
 */